package com.aop;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.aspectj.lang.JoinPoint;

public class LogAspect {
	protected final Log log = LogFactory.getLog(getClass());
	
	public void before(JoinPoint call) {
		String className = call.getTarget().getClass().getName();
		String methodName = call.getSignature().getName();
		String params = "";
		for (int i = 0; i < call.getArgs().length; i++) {
			params += call.getArgs()[i] + ",";
		}
		if (params.length() > 0)
			params = params.substring(0, params.length() - 1);
		log.info(className + "." + methodName + "(" + params
				+ ")");
	}

	public void afterReturn() {
		log.info("afterReturn advice");
	}

	public void after() {
		log.info("after advice");
	}

	public void afterThrowing() {
		log.info("afterThrow advice");
	}
}